/**
 * 
 */
package com.base.myproject.client.ui.Model;

import java.io.Serializable;

import com.extjs.gxt.ui.client.data.BaseTreeModel;

/**
 * 树形结构的model
 * @author zgw
 *2009-7-11 上午10:19:42
 * javazgw@gmail.com
 */
public class TreeModel extends BaseTreeModel implements Serializable {


//	static String[][] strarr = new String[][]{
//			{"1","zz","zz"},
//			{"1001","zgw","zz"},
//			{"10010001","zgw01","zz"},
//			{"10010001","zgw01","zz"},
//			{"10010001","zgw01","zz"},
//	
//	};
	  private static int ID = 0;
	  
	  public TreeModel() {
	    set("id", ID++);
	   
	  }

	  public TreeModel(String menucode) {
	    set("id", ID++);
	    set("menucode", menucode);
	   
	  }
	  public TreeModel(String menucode,String menuname) {
		    set("id", ID++);
		    set("menucode", menucode);
		    set("menuname", menuname);
		   
		  }
	  public TreeModel(String name, BaseTreeModel[] children) {
	    this(name);
	    for (int i = 0; i < children.length; i++) {
	      add(children[i]);
	    }
	  }

	  public Integer getId() {
	    return (Integer) get("id");
	  }

	  public String getName() {
	    return (String) get("menucode");
	  }

	  public String toString() {
	    return getName();
	  }
	  
	  public static TreeModel get123(String[][] strarr)
	  {
		  TreeModel r = new TreeModel("root");
		  java.util.Map<String, TreeModel> h = new java.util.HashMap<String, TreeModel>();
		  for(int i=0;i<strarr.length;i++)
		  {
			  if(strarr[i][0].length()!=12)
			  {
				  TreeModel ttemp = new TreeModel(strarr[i][0],strarr[i][1]);
				  h.put(strarr[i][0].length()/4+"", ttemp);
				  if(strarr[i][0].length()/4!=1)
				  {
					  h.get((strarr[i][0].length()/4 - 1)+"").add(ttemp);
				  }
				  else
				  {
					  r.add(ttemp);
				  }
			  }
			  else
			  {
				  Menuitem mtemp = new Menuitem(strarr[i][0],strarr[i][1]);
				  h.get((strarr[i][0].length()/4 - 1)+"").add(mtemp);
			  }
		  }
		  
		  return r;
		  
	  }
	/*  public static TreeModel getTreeModel() {
		  TreeModel[] folders = new TreeModel[] {
		        new TreeModel("Beethoven",
		            new TreeModel[] {

		                new TreeModel("Quartets",
		                    new Menuitem[] {
		                        new Menuitem("Six String Quartets", "Beethoven", "Quartets"),
		                        new Menuitem("Three String Quartets", "Beethoven", "Quartets"),
		                        new Menuitem("Grosse Fugue for String Quartets", "Beethoven",
		                            "Quartets"),}),
		                new TreeModel("Sonatas", new Menuitem[] {
		                    new Menuitem("Sonata in A Minor", "Beethoven", "Sonatas"),
		                    new Menuitem("Sonata in F Major", "Beethoven", "Sonatas"),}),

		                new TreeModel("Concertos", new Menuitem[] {
		                    new Menuitem("No. 1 - C", "Beethoven", "Concertos"),
		                    new Menuitem("No. 2 - B-Flat Major", "Beethoven", "Concertos"),
		                    new Menuitem("No. 3 - C Minor", "Beethoven", "Concertos"),
		                    new Menuitem("No. 4 - G Major", "Beethoven", "Concertos"),
		                    new Menuitem("No. 5 - E-Flat Major", "Beethoven", "Concertos"),}),

		                new TreeModel("Symphonies", new Menuitem[] {
		                    new Menuitem("No. 1 - C Major", "Beethoven", "Symphonies"),
		                    new Menuitem("No. 2 - D Major", "Beethoven", "Symphonies"),
		                    new Menuitem("No. 3 - E-Flat Major", "Beethoven", "Symphonies"),
		                    new Menuitem("No. 4 - B-Flat Major", "Beethoven", "Symphonies"),
		                    new Menuitem("No. 5 - C Minor", "Beethoven", "Symphonies"),
		                    new Menuitem("No. 6 - F Major", "Beethoven", "Symphonies"),
		                    new Menuitem("No. 7 - A Major", "Beethoven", "Symphonies"),
		                    new Menuitem("No. 8 - F Major", "Beethoven", "Symphonies"),
		                    new Menuitem("No. 9 - D Minor", "Beethoven", "Symphonies"),}),}),
		        new TreeModel("Brahms",
		            new TreeModel[] {
		                new TreeModel("Concertos", new Menuitem[] {
		                    new Menuitem("Violin Concerto", "Brahms", "Concertos"),
		                    new Menuitem("Double Concerto - A Minor", "Brahms", "Concertos"),
		                    new Menuitem("Piano Concerto No. 1 - D Minor", "Brahms", "Concertos"),
		                    new Menuitem("Piano Concerto No. 2 - B-Flat Major", "Brahms",
		                        "Concertos"),}),
		                new TreeModel("Quartets",
		                    new Menuitem[] {
		                        new Menuitem("Piano Quartet No. 1 - G Minor", "Brahms", "Quartets"),
		                        new Menuitem("Piano Quartet No. 2 - A Major", "Brahms", "Quartets"),
		                        new Menuitem("Piano Quartet No. 3 - C Minor", "Brahms", "Quartets"),
		                        new Menuitem("String Quartet No. 3 - B-Flat Minor", "Brahms",
		                            "Quartets"),}),
		                new TreeModel("Sonatas", new Menuitem[] {
		                    new Menuitem("Two Sonatas for Clarinet - F Minor", "Brahms", "Sonatas"),
		                    new Menuitem("Two Sonatas for Clarinet - E-Flat Major", "Brahms",
		                        "Sonatas"),}),
		                new TreeModel("Symphonies", new Menuitem[] {
		                    new Menuitem("No. 1 - C Minor", "Brahms", "Symphonies"),
		                    new Menuitem("No. 2 - D Minor", "Brahms", "Symphonies"),
		                    new Menuitem("No. 3 - F Major", "Brahms", "Symphonies"),
		                    new Menuitem("No. 4 - E Minor", "Brahms", "Symphonies"),}),}),
		        new TreeModel("Mozart", new TreeModel[] {new TreeModel("Concertos", new Menuitem[] {
		            new Menuitem("Piano Concerto No. 12", "Mozart", "Concertos"),
		            new Menuitem("Piano Concerto No. 17", "Mozart", "Concertos"),
		            new Menuitem("Clarinet Concerto", "Mozart", "Concertos"),
		            new Menuitem("Violin Concerto No. 5", "Mozart", "Concertos"),
		            new Menuitem("Violin Concerto No. 4", "Mozart", "Concertos"),}),}),};

		    TreeModel root = new TreeModel("root");
	
		    for (int i = 0; i < folders.length; i++) {
		      root.add((TreeModel) folders[i]);
		    }
		   
		    
		    return root;
		  }*/
public static void main(String[] argv)
{
	String[][] strarr = new String[][]{
			{"1","zz"},
			{"1001","zgw"},
			{"100101","zgw01"}
	
	};

	
	

	
}
}
